home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / watcom / w_modey / fixed32.hpp < prev    next >
C/C++ Source or Header  |  1994-02-12  |  1KB  |  40 lines

  1. #ifndef FIXEDPOINT_HPP
  2.     #define FIXEDPOINT_HPP
  3.  
  4. typedef long Fixed32;          // 16.16 FixedPoint
  5. typedef unsigned char Iangle;  // Integer angle (0..255)
  6.  
  7. /* Macros for Type Conversion */
  8. #define INT_TO_FIXED(x) ((x) << 16)
  9. #define FIXED_TO_INT(x) ((x) >> 16)
  10. #define ROUND_FIXED_TO_INT(x) (((x) + 0x8000) >> 16)
  11.  
  12. // Loads Fixed32 datafiles
  13. void initFixed32(void);
  14.  
  15. // Common math functions
  16. void CosSin(Iangle theta, Fixed32 *Cos, Fixed32 *Sin);
  17.  
  18. Fixed32 FixedMul(Fixed32 num1, Fixed32 num2);
  19. #pragma aux FixedMul =      \
  20.     "imul edx"              \
  21.     "add eax, 8000h"        \
  22.     "adc edx, 0"            \
  23.     "shrd eax, edx, 16"     \
  24.     parm caller [eax] [edx] \
  25.     value [eax]             \
  26.     modify [eax edx];
  27.  
  28. Fixed32 FixedDiv(Fixed32 numer, Fixed32 denom);  // No rounding!
  29. #pragma aux FixedDiv =      \
  30.     "xor eax, eax"          \
  31.     "shrd eax, edx, 16"     \
  32.     "sar edx, 16"           \
  33.     "idiv ebx"              \
  34.     parm caller [edx] [ebx] \
  35.     value [eax]             \
  36.     modify [eax ebx edx];
  37.  
  38. #endif
  39.  
  40.